package com.liankuan.console.controller.vo.user;

import com.liankuan.console.dto.User;
import com.liankuan.console.dto.UserStrategy;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserStrategyVO {
    private static Map<Integer, String> roleMap = new HashMap<Integer, String>() {
        {
            put(1, "创建者");
            put(2, "可编辑策略");
            put(3, "仅可查看策略");
            put(4, "无权");
        }
    };
    private Integer id;
    private String name;
    private String level;

    public UserStrategyVO(User user, UserStrategy userStrategy) {
        this.id = user.getId();
        this.name = user.getName();

        if (userStrategy != null) {
            this.level = roleMap.get(userStrategy.getLevel());
        } else {
            //如果找不到则就是无权
            this.level = roleMap.get(4);
        }

    }
}
